package com.liuh.fram;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.liuh.fram.log.Log4jLogExtra;

/**
 * @note 线程池管理
 * @author liuh
 * */
public class ThreadManager {

	Log4jLogExtra log4jExtra = new Log4jLogExtra(ThreadManager.class);

	private static ThreadManager instance = null;

	private ExecutorService executorService = null;

	public static ThreadManager getInstance() {
		if (instance == null) {
			synchronized (String.class) {
				if (instance == null)
					instance = new ThreadManager();
			}
		}
		return instance;
	}

	private ThreadManager() {
		executorService = Executors.newFixedThreadPool(10);
		log4jExtra.debug("初始化线程池");
	}

	// 获取线程池
	public ExecutorService getExecutorService() {
		return executorService;
	}

	// 关闭线程池
	public void colseExecutor() {
		executorService.shutdown();
		log4jExtra.debug("关闭线程池");
	}
}